package com.care.doctor.remote.factory;

import com.care.common.core.domain.Result;
import com.care.doctor.common.domain.DTOHospital;
import com.care.doctor.common.req.ListReq;
import com.care.doctor.remote.HospitalRemoteService;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @Author: 靳家振
 * @Date: 2024/3/23 18:24
 * @Description:
 **/

@Component
public class RemoteHospitalFallbackFactory implements FallbackFactory<HospitalRemoteService> {
    private static final Logger log = LoggerFactory.getLogger (RemoteHospitalFallbackFactory.class);
    @Override
    public HospitalRemoteService create(Throwable cause) {
        log.error("医院列表服务异常:{}", cause.getMessage ());
        return new HospitalRemoteService () {
            @Override
            public Result<PageInfo<DTOHospital>> findHospital(ListReq req) {
                return Result.error ("医院列表服务异常，请稍后再试");
            }
        };
    }
}
